package web.socket2;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.Arrays;

public class testFileChanle {
	
	public static void main(String[] args) throws Exception {
		File d=new File("d:zsw2.txt");
		if(!d.exists()) {
			d.createNewFile();
		}
		FileOutputStream out=new FileOutputStream(d);
		
		
		FileChannel channel = out.getChannel();
		
		byte[] d2=new byte[] {97,98,99,100,101};
		
		byte[] d3="曾".getBytes("gbk");		
		byte[] d4="曾少".getBytes("gbk");	
		byte[] d5="1".getBytes("gbk");	
		byte[] d6="\r\n".getBytes("gbk");	
		
		
		ByteBuffer buffer=ByteBuffer.allocate(10);
		
		for (int i = 0; i < d2.length; i++) {
			buffer.put(d2[i]);
		}
		
		buffer.flip();
		
		channel.write(buffer);
		out.flush();
		out.close();
	
	}

}
